<?php
declare (strict_types = 1);

namespace app\api\controller;

use app\BaseController;
use app\lib\exception\BaseException;
use think\facade\Cache;


class SendCode extends BaseController
{

    public function index()
    {
         (new \app\validate\api\SendCode())->goCheck();
         $params= request()->param();
         $sendCode=new ChuanglanSmsApi();
         $code = mt_rand(10000, 99999);

         if(!is_null(Cache::get($params['mobile'])))  throw new BaseException(['msg' => '您的操作太頻繁，請稍後再試！']);
         Cache::set($params['mobile'],$code,60);
//          $sendCode->sendInternational($params['areacode'].$params['mobile'], '【睿創星河】您的驗證碼為：' . $code);
          return $this->success($code);
    }


}
